package com.jic.product.impl;

import java.lang.Long;
import java.util.List;

import com.jic.product.entity.ProductPropertyValueRelation;
import com.jic.product.mapper.ProductPropertyValueRelationMapper;
import com.jic.product.service.ProductPropertyValueRelationService;
import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 商品属性值
 * @author : 
 * @email : 
 * @since : 2020-01-10 07:03:01
 * @version : v1.0.0
 */
@Service
public class ProductPropertyValueRelationServiceImpl implements ProductPropertyValueRelationService{

    @Autowired
    private ProductPropertyValueRelationMapper productPropertyValueRelationMapper;

    @Override
    public long insert(ProductPropertyValueRelation productPropertyValueRelation) {
        long flag = productPropertyValueRelationMapper.insert(productPropertyValueRelation);
        return flag;
    }

    @Override
    public long delete(Long id) {
        return productPropertyValueRelationMapper.delete(id);
    }

    @Override
    public long update(ProductPropertyValueRelation productPropertyValueRelation) {
        return productPropertyValueRelationMapper.update(productPropertyValueRelation);
    }

    @Override
    public ProductPropertyValueRelation queryByPrimaryKey(Long id){
        return productPropertyValueRelationMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<ProductPropertyValueRelation> query(ProductPropertyValueRelation productPropertyValueRelation){
        return productPropertyValueRelationMapper.query(productPropertyValueRelation);
    }

    @Override
    public PageResult<ProductPropertyValueRelation> queryPage(ProductPropertyValueRelation productPropertyValueRelation, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<ProductPropertyValueRelation> list = productPropertyValueRelationMapper.queryPage(startIndex, pageQuery.getLimit(), productPropertyValueRelation);
        long count = productPropertyValueRelationMapper.queryPageCount(productPropertyValueRelation);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }
}